<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use backend\models\AdminInfo;
use backend\models\Image;
/* @var $this yii\web\View */
/* @var $model backend\models\Vr */

$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Build Cities'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;

$show_all_item_id_img = '';
foreach (explode(',', \backend\models\VrPos::getAllItemByVr($model->id)) as $value) {
    $item = \backend\models\VrPos::getItemInfo($value) ;
    if($item !== null && (int)$item->img_small_id > 0){
        $show_all_item_id_img .= "<img width='10%' src='" . Image::show_image($item->img_small_id) . "'>";
    }
}

?>
<div class="build-city-view">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
    <?php if(AdminInfo::check_hasoperator(Yii::$app->user->identity->id,Yii::$app->user->identity->id,'edit')){?>
        <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
        ]) ?>
     <?php }?>
    </p>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            'name',
            'city',
            'village',
            'house_type',
            'area',
			'cost',
            'brief',
            [
                'attribute' => 'vr_flag',
                'value'=>getValueFromArray($model->vr_flag, \backend\models\Vr::$vr_flag)
            ],
            [
                'attribute' => 'app_return',
                'value'=>getValueFromArray($model->app_return, \backend\models\Vr::$app_return)
            ],
            'vr_url',
            [
                'attribute' => 'vr_img',
                'value'=>!empty($model->vr_img)?"<img width='10%' src='".Image::show_image($model->vr_img)."'>":'无图','format' => 'raw',
            ],
            [
                'label' => '单品图',
                'value' => !empty($show_all_item_id_img) ? $show_all_item_id_img:'暂未选单品',
                'format' => 'raw',
            ],
        ],
    ]) ?>

</div>
